import {ApiProperty} from '@nestjs/swagger';
import {ModelOptions, prop, Ref,} from '@typegoose/typegoose';
import {IsNotEmpty} from "class-validator";

@ModelOptions({
  schemaOptions: {
    timestamps: true,
    versionKey: false
  }
})
export class Category {

  @ApiProperty({description: '分类名称'})
  @IsNotEmpty({message: '分类名称是必须的'})
  @prop()
  name: string

  @ApiProperty({description: '上级分类'})
  @prop({ref: Category})
  parent: Ref<Category>
}
